import { CopyInfoPanelBase } from "../CopyInfoPanelBase";
import { BossConfig } from "../../../resource/BossConfig";
import { Language } from "../../../../../extend/language/Language";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { TextAlign } from "../../../../../flashx/textLayout/formats/TextAlign";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { PageItemRenderer } from "../../common/renderers/PageItemRenderer";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
//class LevelSealInfoPanel
    
    export  class LevelSealInfoPanel extends CopyInfoPanelBase
    {
        constructor()
        {
            super();
            this.initView();
            updatePosition();
            return;
        }

        public updateView(arg1: string, arg2: string, arg3: string): void
        {
            this._txtTitle.htmlText = arg1;
            this._txt1.htmlText = arg2;
            this._txtDesc.htmlText = arg3;
            return;
        }

        public updateCondition(arg1: Map<any, any> /* flash.utils.Dictionary */): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=null;
            if (arg1) 
            {
                loc1 = [];
                var loc6=0;
                var loc7=arg1;
                for (loc2 in loc7) 
                {
                    loc1.push(parseInt(loc2));
                }
                loc1.sort(Array.NUMERIC);
                loc3 = "";
                loc6 = 0;
                loc7 = loc1;
                for(loc4 of loc7) 
                {
                    if (!(loc5 = BossConfig.instance.getInfoByName(loc4))) 
                    {
                        continue;
                    }
                    loc3 = (loc3 = Language.getString(80186)) + ("\n\t" + loc5.name + "  （" + arg1[loc4.toString()] + "/1）");
                }
                this._txtCondition.htmlText = loc3;
            }
            else 
            {
                this._txtCondition.htmlText = "";
            }
            this.resize();
            return;
        }

        public updateBonus(arg1: Array<any>): void
        {
            if (arg1 == null || arg1.length == 0) 
            {
                this._bonuses.removeAll();
                DisplayUtil.removeMe(this._txtBonus);
                DisplayUtil.removeMe(this._bonusTile);
            }
            else 
            {
                this._bonuses.removeAll();
                this._bonuses.addItems(arg1);
                this._bonusTile.dataProvider = this._bonuses;
                this._bonusTile.height = this._bonusTile.rowHeight * Math.ceil(this._bonuses.length / 5) + 5;
                _bodySp.addChild(this._txtBonus);
                _bodySp.addChild(this._bonusTile);
            }
            this.resize();
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            this._txtTitle = ObjCreate.createGTextField("", 0, 10, 260, 20, _bodySp);
            loc1 = this._txtTitle.defaultTextFormat;
            loc1.align = TextAlign.CENTER;
            this._txtTitle.defaultTextFormat = loc1;
            this._txt1 = ObjCreate.createGTextField("", 10, 30, 240, 40, _bodySp);
            loc1 = this._txt1.defaultTextFormat;
            loc1.size = 12;
            this._txt1.defaultTextFormat = loc1;
            this._txtDesc = ObjCreate.createGTextField("", 10, 50, 240, 120, _bodySp);
            this._txtDesc.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._txtDesc.wordWrap = true;
            this._txtDesc.mouseEnabled = false;
            loc1 = this._txtDesc.defaultTextFormat;
            loc1.size = 12;
            loc1.leading = 3;
            this._txtDesc.defaultTextFormat = loc1;
            this._txtCondition = ObjCreate.createGTextField("", 10, 90, 240, 20, _bodySp);
            this._txtCondition.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._txtCondition.wordWrap = true;
            this._txtCondition.mouseEnabled = false;
            loc1 = this._txtCondition.defaultTextFormat;
            loc1.size = 12;
            loc1.leading = 3;
            this._txtCondition.defaultTextFormat = loc1;
            this._txtBonus = ObjCreate.createGTextField("", 10, 110, 240, 40, _bodySp);
            loc1 = this._txtBonus.defaultTextFormat;
            loc1.size = 12;
            this._txtBonus.defaultTextFormat = loc1;
            this._txtBonus.htmlText = Language.getString(80180);
            this._bonuses = new DataProvider();
            this._bonusTile = ObjCreate.createTileList(20, 130, 220, 85, _bodySp);
            this._bonusTile.setStyle("cellRenderer", PageItemRenderer);
            this._bonusTile.rowHeight = 41;
            this._bonusTile.columnWidth = 41;
            this._bonusTile.scrollPolicy = ScrollPolicy.OFF;
            this._bonusTile.dataProvider = this._bonuses;
            return;
        }

        /* internal  */resize(): void
        {
            this._txtCondition.y = this._txtDesc.y + this._txtDesc.height + 5;
            if (this._bonuses && this._bonuses.length > 0) 
            {
                this._txtBonus.y = this._txtCondition.y + this._txtCondition.height + 10;
                this._bonusTile.y = this._txtBonus.y + 25;
                _bg.height = this._bonusTile.y + this._bonusTile.height + 10;
            }
            else 
            {
                _bg.height = this._txtCondition.y + this._txtCondition.height + 15;
            }
            return;
        }

        /* internal */ /* var */_txtTitle: GTextFiled;

        /* internal */ /* var */_txt1: GTextFiled;

        /* internal */ /* var */_txtDesc: GTextFiled;

        /* internal */ /* var */_txtCondition: GTextFiled;

        /* internal */ /* var */_txtBonus: GTextFiled;

        /* internal */ /* var */_bonuses: DataProvider;

        /* internal */ /* var */_bonusTile: GTileList;
    }
